package training.osms.view.category;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import training.osms.controller.category.CategoryController;
import training.osms.model.category.Category;
import training.osms.view.OsmsUtil;

@ManagedBean
@SessionScoped
public class EditCategoryForm {

	private Category category;
	private boolean categorySaved;

	public EditCategoryForm(){
	}

	public String initialize(Category category) {
		this.category = category;
		this.categorySaved = false;
		return "editCategory";
	}
	
	public void saveCategory(){
		CategoryController controller = new CategoryController();		
		controller.saveCategory(this.category);
		OsmsUtil.sendMessage("Category succesfully saved.", OsmsUtil.INFO);
		setCategorySaved(true);
	}
	

	public Category getCategory() {
		return category;
	}

	public void setCategory(Category category) {
		this.category = category;
	}

	public boolean getCategorySaved() {
		return categorySaved;
	}

	public void setCategorySaved(boolean categorySaved) {
		this.categorySaved = categorySaved;
	}
}
